use ::libc;
extern "C" {
    fn free(_: *mut libc::c_void);
    fn strcmp(_: *const i8, _: *const i8) -> i32;
    fn xcalloc(_: size_t, _: size_t) -> *mut libc::c_void;
    fn xasprintf(_: *mut *mut i8, _: *const i8, _: ...) -> i32;
    fn utf8_stravis(
        _: *mut *mut i8,
        _: *const i8,
        _: i32,
    ) -> i32;
}
pub type __u_int = u32;
pub type u_int = __u_int;
pub type size_t = u64;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct hyperlinks {
    pub next_inner: u_int,
    pub by_inner: hyperlinks_by_inner_tree,
    pub by_uri: hyperlinks_by_uri_tree,
    pub references: u_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct hyperlinks_by_uri_tree {
    pub rbh_root: *mut hyperlinks_uri,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct hyperlinks_uri {
    pub tree: *mut hyperlinks,
    pub inner: u_int,
    pub internal_id: *const i8,
    pub external_id: *const i8,
    pub uri: *const i8,
    pub list_entry: C2RustUnnamed_1,
    pub by_inner_entry: C2RustUnnamed_0,
    pub by_uri_entry: C2RustUnnamed,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed {
    pub rbe_left: *mut hyperlinks_uri,
    pub rbe_right: *mut hyperlinks_uri,
    pub rbe_parent: *mut hyperlinks_uri,
    pub rbe_color: i32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_0 {
    pub rbe_left: *mut hyperlinks_uri,
    pub rbe_right: *mut hyperlinks_uri,
    pub rbe_parent: *mut hyperlinks_uri,
    pub rbe_color: i32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_1 {
    pub tqe_next: *mut hyperlinks_uri,
    pub tqe_prev: *mut *mut hyperlinks_uri,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct hyperlinks_by_inner_tree {
    pub rbh_root: *mut hyperlinks_uri,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct hyperlinks_list {
    pub tqh_first: *mut hyperlinks_uri,
    pub tqh_last: *mut *mut hyperlinks_uri,
}
static mut hyperlinks_next_external_id: i64 = 1 as i32 as i64;
static mut global_hyperlinks_count: u_int = 0;
static mut global_hyperlinks: hyperlinks_list = hyperlinks_list {
    tqh_first: 0 as *const hyperlinks_uri as *mut hyperlinks_uri,
    tqh_last: 0 as *const *mut hyperlinks_uri as *mut *mut hyperlinks_uri,
};
unsafe extern "C" fn hyperlinks_by_uri_cmp(
    mut left: *mut hyperlinks_uri,
    mut right: *mut hyperlinks_uri,
) -> i32 {
    let mut r: i32 = 0;
    if *(*left).internal_id as i32 == '\0' as i32
        || *(*right).internal_id as i32 == '\0' as i32
    {
        if *(*left).internal_id as i32 != '\0' as i32 {
            return -(1 as i32);
        }
        if *(*right).internal_id as i32 != '\0' as i32 {
            return 1 as i32;
        }
        return ((*left).inner).wrapping_sub((*right).inner) as i32;
    }
    r = strcmp((*left).internal_id, (*right).internal_id);
    if r != 0 as i32 {
        return r;
    }
    return strcmp((*left).uri, (*right).uri);
}
unsafe extern "C" fn hyperlinks_by_uri_tree_RB_INSERT_COLOR(
    mut head: *mut hyperlinks_by_uri_tree,
    mut elm: *mut hyperlinks_uri,
) {
    let mut parent: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut gparent: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut tmp: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    loop {
        parent = (*elm).by_uri_entry.rbe_parent;
        if parent.is_null() || (*parent).by_uri_entry.rbe_color != 1 as i32 {
            break;
        }
        gparent = (*parent).by_uri_entry.rbe_parent;
        if parent == (*gparent).by_uri_entry.rbe_left {
            tmp = (*gparent).by_uri_entry.rbe_right;
            if !tmp.is_null() && (*tmp).by_uri_entry.rbe_color == 1 as i32 {
                (*tmp).by_uri_entry.rbe_color = 0 as i32;
                (*parent).by_uri_entry.rbe_color = 0 as i32;
                (*gparent).by_uri_entry.rbe_color = 1 as i32;
                elm = gparent;
            } else {
                if (*parent).by_uri_entry.rbe_right == elm {
                    tmp = (*parent).by_uri_entry.rbe_right;
                    (*parent).by_uri_entry.rbe_right = (*tmp).by_uri_entry.rbe_left;
                    if !((*parent).by_uri_entry.rbe_right).is_null() {
                        (*(*tmp).by_uri_entry.rbe_left).by_uri_entry.rbe_parent = parent;
                    }
                    (*tmp).by_uri_entry.rbe_parent = (*parent).by_uri_entry.rbe_parent;
                    if !((*tmp).by_uri_entry.rbe_parent).is_null() {
                        if parent == (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left {
                            (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left = tmp;
                        } else {
                            (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_right = tmp;
                        }
                    } else {
                        (*head).rbh_root = tmp;
                    }
                    (*tmp).by_uri_entry.rbe_left = parent;
                    (*parent).by_uri_entry.rbe_parent = tmp;
                    !((*tmp).by_uri_entry.rbe_parent).is_null();
                    tmp = parent;
                    parent = elm;
                    elm = tmp;
                }
                (*parent).by_uri_entry.rbe_color = 0 as i32;
                (*gparent).by_uri_entry.rbe_color = 1 as i32;
                tmp = (*gparent).by_uri_entry.rbe_left;
                (*gparent).by_uri_entry.rbe_left = (*tmp).by_uri_entry.rbe_right;
                if !((*gparent).by_uri_entry.rbe_left).is_null() {
                    (*(*tmp).by_uri_entry.rbe_right).by_uri_entry.rbe_parent = gparent;
                }
                (*tmp).by_uri_entry.rbe_parent = (*gparent).by_uri_entry.rbe_parent;
                if !((*tmp).by_uri_entry.rbe_parent).is_null() {
                    if gparent == (*(*gparent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left {
                        (*(*gparent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left = tmp;
                    } else {
                        (*(*gparent).by_uri_entry.rbe_parent).by_uri_entry.rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).by_uri_entry.rbe_right = gparent;
                (*gparent).by_uri_entry.rbe_parent = tmp;
                !((*tmp).by_uri_entry.rbe_parent).is_null();
            }
        } else {
            tmp = (*gparent).by_uri_entry.rbe_left;
            if !tmp.is_null() && (*tmp).by_uri_entry.rbe_color == 1 as i32 {
                (*tmp).by_uri_entry.rbe_color = 0 as i32;
                (*parent).by_uri_entry.rbe_color = 0 as i32;
                (*gparent).by_uri_entry.rbe_color = 1 as i32;
                elm = gparent;
            } else {
                if (*parent).by_uri_entry.rbe_left == elm {
                    tmp = (*parent).by_uri_entry.rbe_left;
                    (*parent).by_uri_entry.rbe_left = (*tmp).by_uri_entry.rbe_right;
                    if !((*parent).by_uri_entry.rbe_left).is_null() {
                        (*(*tmp).by_uri_entry.rbe_right).by_uri_entry.rbe_parent = parent;
                    }
                    (*tmp).by_uri_entry.rbe_parent = (*parent).by_uri_entry.rbe_parent;
                    if !((*tmp).by_uri_entry.rbe_parent).is_null() {
                        if parent == (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left {
                            (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left = tmp;
                        } else {
                            (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_right = tmp;
                        }
                    } else {
                        (*head).rbh_root = tmp;
                    }
                    (*tmp).by_uri_entry.rbe_right = parent;
                    (*parent).by_uri_entry.rbe_parent = tmp;
                    !((*tmp).by_uri_entry.rbe_parent).is_null();
                    tmp = parent;
                    parent = elm;
                    elm = tmp;
                }
                (*parent).by_uri_entry.rbe_color = 0 as i32;
                (*gparent).by_uri_entry.rbe_color = 1 as i32;
                tmp = (*gparent).by_uri_entry.rbe_right;
                (*gparent).by_uri_entry.rbe_right = (*tmp).by_uri_entry.rbe_left;
                if !((*gparent).by_uri_entry.rbe_right).is_null() {
                    (*(*tmp).by_uri_entry.rbe_left).by_uri_entry.rbe_parent = gparent;
                }
                (*tmp).by_uri_entry.rbe_parent = (*gparent).by_uri_entry.rbe_parent;
                if !((*tmp).by_uri_entry.rbe_parent).is_null() {
                    if gparent == (*(*gparent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left {
                        (*(*gparent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left = tmp;
                    } else {
                        (*(*gparent).by_uri_entry.rbe_parent).by_uri_entry.rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).by_uri_entry.rbe_left = gparent;
                (*gparent).by_uri_entry.rbe_parent = tmp;
                !((*tmp).by_uri_entry.rbe_parent).is_null();
            }
        }
    }
    (*(*head).rbh_root).by_uri_entry.rbe_color = 0 as i32;
}
unsafe extern "C" fn hyperlinks_by_uri_tree_RB_FIND(
    mut head: *mut hyperlinks_by_uri_tree,
    mut elm: *mut hyperlinks_uri,
) -> *mut hyperlinks_uri {
    let mut tmp: *mut hyperlinks_uri = (*head).rbh_root;
    let mut comp: i32 = 0;
    while !tmp.is_null() {
        comp = hyperlinks_by_uri_cmp(elm, tmp);
        if comp < 0 as i32 {
            tmp = (*tmp).by_uri_entry.rbe_left;
        } else if comp > 0 as i32 {
            tmp = (*tmp).by_uri_entry.rbe_right;
        } else {
            return tmp;
        }
    }
    return std::ptr::null_mut::<hyperlinks_uri>();
}
unsafe extern "C" fn hyperlinks_by_uri_tree_RB_REMOVE(
    mut head: *mut hyperlinks_by_uri_tree,
    mut elm: *mut hyperlinks_uri,
) -> *mut hyperlinks_uri {
    let mut current_block: u64;
    let mut child: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut parent: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut old: *mut hyperlinks_uri = elm;
    let mut color: i32 = 0;
    if ((*elm).by_uri_entry.rbe_left).is_null() {
        child = (*elm).by_uri_entry.rbe_right;
        current_block = 7245201122033322888;
    } else if ((*elm).by_uri_entry.rbe_right).is_null() {
        child = (*elm).by_uri_entry.rbe_left;
        current_block = 7245201122033322888;
    } else {
        let mut left: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
        elm = (*elm).by_uri_entry.rbe_right;
        loop {
            left = (*elm).by_uri_entry.rbe_left;
            if left.is_null() {
                break;
            }
            elm = left;
        }
        child = (*elm).by_uri_entry.rbe_right;
        parent = (*elm).by_uri_entry.rbe_parent;
        color = (*elm).by_uri_entry.rbe_color;
        if !child.is_null() {
            (*child).by_uri_entry.rbe_parent = parent;
        }
        if !parent.is_null() {
            if (*parent).by_uri_entry.rbe_left == elm {
                (*parent).by_uri_entry.rbe_left = child;
            } else {
                (*parent).by_uri_entry.rbe_right = child;
            }
        } else {
            (*head).rbh_root = child;
        }
        if (*elm).by_uri_entry.rbe_parent == old {
            parent = elm;
        }
        (*elm).by_uri_entry = (*old).by_uri_entry;
        if !((*old).by_uri_entry.rbe_parent).is_null() {
            if (*(*old).by_uri_entry.rbe_parent).by_uri_entry.rbe_left == old {
                (*(*old).by_uri_entry.rbe_parent).by_uri_entry.rbe_left = elm;
            } else {
                (*(*old).by_uri_entry.rbe_parent).by_uri_entry.rbe_right = elm;
            }
        } else {
            (*head).rbh_root = elm;
        }
        (*(*old).by_uri_entry.rbe_left).by_uri_entry.rbe_parent = elm;
        if !((*old).by_uri_entry.rbe_right).is_null() {
            (*(*old).by_uri_entry.rbe_right).by_uri_entry.rbe_parent = elm;
        }
        if !parent.is_null() {
            left = parent;
            loop {
                left = (*left).by_uri_entry.rbe_parent;
                if left.is_null() {
                    break;
                }
            }
        }
        current_block = 3443566586990830109;
    }
    match current_block {
        7245201122033322888 => {
            parent = (*elm).by_uri_entry.rbe_parent;
            color = (*elm).by_uri_entry.rbe_color;
            if !child.is_null() {
                (*child).by_uri_entry.rbe_parent = parent;
            }
            if !parent.is_null() {
                if (*parent).by_uri_entry.rbe_left == elm {
                    (*parent).by_uri_entry.rbe_left = child;
                } else {
                    (*parent).by_uri_entry.rbe_right = child;
                }
            } else {
                (*head).rbh_root = child;
            }
        }
        _ => {}
    }
    if color == 0 as i32 {
        hyperlinks_by_uri_tree_RB_REMOVE_COLOR(head, parent, child);
    }
    return old;
}
unsafe extern "C" fn hyperlinks_by_uri_tree_RB_REMOVE_COLOR(
    mut head: *mut hyperlinks_by_uri_tree,
    mut parent: *mut hyperlinks_uri,
    mut elm: *mut hyperlinks_uri,
) {
    let mut tmp: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    while (elm.is_null() || (*elm).by_uri_entry.rbe_color == 0 as i32)
        && elm != (*head).rbh_root
    {
        if (*parent).by_uri_entry.rbe_left == elm {
            tmp = (*parent).by_uri_entry.rbe_right;
            if (*tmp).by_uri_entry.rbe_color == 1 as i32 {
                (*tmp).by_uri_entry.rbe_color = 0 as i32;
                (*parent).by_uri_entry.rbe_color = 1 as i32;
                tmp = (*parent).by_uri_entry.rbe_right;
                (*parent).by_uri_entry.rbe_right = (*tmp).by_uri_entry.rbe_left;
                if !((*parent).by_uri_entry.rbe_right).is_null() {
                    (*(*tmp).by_uri_entry.rbe_left).by_uri_entry.rbe_parent = parent;
                }
                (*tmp).by_uri_entry.rbe_parent = (*parent).by_uri_entry.rbe_parent;
                if !((*tmp).by_uri_entry.rbe_parent).is_null() {
                    if parent == (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left {
                        (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left = tmp;
                    } else {
                        (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).by_uri_entry.rbe_left = parent;
                (*parent).by_uri_entry.rbe_parent = tmp;
                !((*tmp).by_uri_entry.rbe_parent).is_null();
                tmp = (*parent).by_uri_entry.rbe_right;
            }
            if (((*tmp).by_uri_entry.rbe_left).is_null()
                || (*(*tmp).by_uri_entry.rbe_left).by_uri_entry.rbe_color == 0 as i32)
                && (((*tmp).by_uri_entry.rbe_right).is_null()
                    || (*(*tmp).by_uri_entry.rbe_right).by_uri_entry.rbe_color == 0 as i32)
            {
                (*tmp).by_uri_entry.rbe_color = 1 as i32;
                elm = parent;
                parent = (*elm).by_uri_entry.rbe_parent;
            } else {
                if ((*tmp).by_uri_entry.rbe_right).is_null()
                    || (*(*tmp).by_uri_entry.rbe_right).by_uri_entry.rbe_color == 0 as i32
                {
                    let mut oleft: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
                    oleft = (*tmp).by_uri_entry.rbe_left;
                    if !oleft.is_null() {
                        (*oleft).by_uri_entry.rbe_color = 0 as i32;
                    }
                    (*tmp).by_uri_entry.rbe_color = 1 as i32;
                    oleft = (*tmp).by_uri_entry.rbe_left;
                    (*tmp).by_uri_entry.rbe_left = (*oleft).by_uri_entry.rbe_right;
                    if !((*tmp).by_uri_entry.rbe_left).is_null() {
                        (*(*oleft).by_uri_entry.rbe_right).by_uri_entry.rbe_parent = tmp;
                    }
                    (*oleft).by_uri_entry.rbe_parent = (*tmp).by_uri_entry.rbe_parent;
                    if !((*oleft).by_uri_entry.rbe_parent).is_null() {
                        if tmp == (*(*tmp).by_uri_entry.rbe_parent).by_uri_entry.rbe_left {
                            (*(*tmp).by_uri_entry.rbe_parent).by_uri_entry.rbe_left = oleft;
                        } else {
                            (*(*tmp).by_uri_entry.rbe_parent).by_uri_entry.rbe_right = oleft;
                        }
                    } else {
                        (*head).rbh_root = oleft;
                    }
                    (*oleft).by_uri_entry.rbe_right = tmp;
                    (*tmp).by_uri_entry.rbe_parent = oleft;
                    !((*oleft).by_uri_entry.rbe_parent).is_null();
                    tmp = (*parent).by_uri_entry.rbe_right;
                }
                (*tmp).by_uri_entry.rbe_color = (*parent).by_uri_entry.rbe_color;
                (*parent).by_uri_entry.rbe_color = 0 as i32;
                if !((*tmp).by_uri_entry.rbe_right).is_null() {
                    (*(*tmp).by_uri_entry.rbe_right).by_uri_entry.rbe_color = 0 as i32;
                }
                tmp = (*parent).by_uri_entry.rbe_right;
                (*parent).by_uri_entry.rbe_right = (*tmp).by_uri_entry.rbe_left;
                if !((*parent).by_uri_entry.rbe_right).is_null() {
                    (*(*tmp).by_uri_entry.rbe_left).by_uri_entry.rbe_parent = parent;
                }
                (*tmp).by_uri_entry.rbe_parent = (*parent).by_uri_entry.rbe_parent;
                if !((*tmp).by_uri_entry.rbe_parent).is_null() {
                    if parent == (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left {
                        (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left = tmp;
                    } else {
                        (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).by_uri_entry.rbe_left = parent;
                (*parent).by_uri_entry.rbe_parent = tmp;
                !((*tmp).by_uri_entry.rbe_parent).is_null();
                elm = (*head).rbh_root;
                break;
            }
        } else {
            tmp = (*parent).by_uri_entry.rbe_left;
            if (*tmp).by_uri_entry.rbe_color == 1 as i32 {
                (*tmp).by_uri_entry.rbe_color = 0 as i32;
                (*parent).by_uri_entry.rbe_color = 1 as i32;
                tmp = (*parent).by_uri_entry.rbe_left;
                (*parent).by_uri_entry.rbe_left = (*tmp).by_uri_entry.rbe_right;
                if !((*parent).by_uri_entry.rbe_left).is_null() {
                    (*(*tmp).by_uri_entry.rbe_right).by_uri_entry.rbe_parent = parent;
                }
                (*tmp).by_uri_entry.rbe_parent = (*parent).by_uri_entry.rbe_parent;
                if !((*tmp).by_uri_entry.rbe_parent).is_null() {
                    if parent == (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left {
                        (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left = tmp;
                    } else {
                        (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).by_uri_entry.rbe_right = parent;
                (*parent).by_uri_entry.rbe_parent = tmp;
                !((*tmp).by_uri_entry.rbe_parent).is_null();
                tmp = (*parent).by_uri_entry.rbe_left;
            }
            if (((*tmp).by_uri_entry.rbe_left).is_null()
                || (*(*tmp).by_uri_entry.rbe_left).by_uri_entry.rbe_color == 0 as i32)
                && (((*tmp).by_uri_entry.rbe_right).is_null()
                    || (*(*tmp).by_uri_entry.rbe_right).by_uri_entry.rbe_color == 0 as i32)
            {
                (*tmp).by_uri_entry.rbe_color = 1 as i32;
                elm = parent;
                parent = (*elm).by_uri_entry.rbe_parent;
            } else {
                if ((*tmp).by_uri_entry.rbe_left).is_null()
                    || (*(*tmp).by_uri_entry.rbe_left).by_uri_entry.rbe_color == 0 as i32
                {
                    let mut oright: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
                    oright = (*tmp).by_uri_entry.rbe_right;
                    if !oright.is_null() {
                        (*oright).by_uri_entry.rbe_color = 0 as i32;
                    }
                    (*tmp).by_uri_entry.rbe_color = 1 as i32;
                    oright = (*tmp).by_uri_entry.rbe_right;
                    (*tmp).by_uri_entry.rbe_right = (*oright).by_uri_entry.rbe_left;
                    if !((*tmp).by_uri_entry.rbe_right).is_null() {
                        (*(*oright).by_uri_entry.rbe_left).by_uri_entry.rbe_parent = tmp;
                    }
                    (*oright).by_uri_entry.rbe_parent = (*tmp).by_uri_entry.rbe_parent;
                    if !((*oright).by_uri_entry.rbe_parent).is_null() {
                        if tmp == (*(*tmp).by_uri_entry.rbe_parent).by_uri_entry.rbe_left {
                            (*(*tmp).by_uri_entry.rbe_parent).by_uri_entry.rbe_left = oright;
                        } else {
                            (*(*tmp).by_uri_entry.rbe_parent).by_uri_entry.rbe_right = oright;
                        }
                    } else {
                        (*head).rbh_root = oright;
                    }
                    (*oright).by_uri_entry.rbe_left = tmp;
                    (*tmp).by_uri_entry.rbe_parent = oright;
                    !((*oright).by_uri_entry.rbe_parent).is_null();
                    tmp = (*parent).by_uri_entry.rbe_left;
                }
                (*tmp).by_uri_entry.rbe_color = (*parent).by_uri_entry.rbe_color;
                (*parent).by_uri_entry.rbe_color = 0 as i32;
                if !((*tmp).by_uri_entry.rbe_left).is_null() {
                    (*(*tmp).by_uri_entry.rbe_left).by_uri_entry.rbe_color = 0 as i32;
                }
                tmp = (*parent).by_uri_entry.rbe_left;
                (*parent).by_uri_entry.rbe_left = (*tmp).by_uri_entry.rbe_right;
                if !((*parent).by_uri_entry.rbe_left).is_null() {
                    (*(*tmp).by_uri_entry.rbe_right).by_uri_entry.rbe_parent = parent;
                }
                (*tmp).by_uri_entry.rbe_parent = (*parent).by_uri_entry.rbe_parent;
                if !((*tmp).by_uri_entry.rbe_parent).is_null() {
                    if parent == (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left {
                        (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_left = tmp;
                    } else {
                        (*(*parent).by_uri_entry.rbe_parent).by_uri_entry.rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).by_uri_entry.rbe_right = parent;
                (*parent).by_uri_entry.rbe_parent = tmp;
                !((*tmp).by_uri_entry.rbe_parent).is_null();
                elm = (*head).rbh_root;
                break;
            }
        }
    }
    if !elm.is_null() {
        (*elm).by_uri_entry.rbe_color = 0 as i32;
    }
}
unsafe extern "C" fn hyperlinks_by_uri_tree_RB_INSERT(
    mut head: *mut hyperlinks_by_uri_tree,
    mut elm: *mut hyperlinks_uri,
) -> *mut hyperlinks_uri {
    let mut tmp: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut parent: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut comp: i32 = 0 as i32;
    tmp = (*head).rbh_root;
    while !tmp.is_null() {
        parent = tmp;
        comp = hyperlinks_by_uri_cmp(elm, parent);
        if comp < 0 as i32 {
            tmp = (*tmp).by_uri_entry.rbe_left;
        } else if comp > 0 as i32 {
            tmp = (*tmp).by_uri_entry.rbe_right;
        } else {
            return tmp;
        }
    }
    (*elm).by_uri_entry.rbe_parent = parent;
    (*elm).by_uri_entry.rbe_right = std::ptr::null_mut::<hyperlinks_uri>();
    (*elm).by_uri_entry.rbe_left = (*elm).by_uri_entry.rbe_right;
    (*elm).by_uri_entry.rbe_color = 1 as i32;
    if !parent.is_null() {
        if comp < 0 as i32 {
            (*parent).by_uri_entry.rbe_left = elm;
        } else {
            (*parent).by_uri_entry.rbe_right = elm;
        }
    } else {
        (*head).rbh_root = elm;
    }
    hyperlinks_by_uri_tree_RB_INSERT_COLOR(head, elm);
    return std::ptr::null_mut::<hyperlinks_uri>();
}
unsafe extern "C" fn hyperlinks_by_inner_cmp(
    mut left: *mut hyperlinks_uri,
    mut right: *mut hyperlinks_uri,
) -> i32 {
    return ((*left).inner).wrapping_sub((*right).inner) as i32;
}
unsafe extern "C" fn hyperlinks_by_inner_tree_RB_NEXT(
    mut elm: *mut hyperlinks_uri,
) -> *mut hyperlinks_uri {
    if !((*elm).by_inner_entry.rbe_right).is_null() {
        elm = (*elm).by_inner_entry.rbe_right;
        while !((*elm).by_inner_entry.rbe_left).is_null() {
            elm = (*elm).by_inner_entry.rbe_left;
        }
    } else if !((*elm).by_inner_entry.rbe_parent).is_null()
        && elm == (*(*elm).by_inner_entry.rbe_parent).by_inner_entry.rbe_left
    {
        elm = (*elm).by_inner_entry.rbe_parent;
    } else {
        while !((*elm).by_inner_entry.rbe_parent).is_null()
            && elm == (*(*elm).by_inner_entry.rbe_parent).by_inner_entry.rbe_right
        {
            elm = (*elm).by_inner_entry.rbe_parent;
        }
        elm = (*elm).by_inner_entry.rbe_parent;
    }
    return elm;
}
unsafe extern "C" fn hyperlinks_by_inner_tree_RB_INSERT_COLOR(
    mut head: *mut hyperlinks_by_inner_tree,
    mut elm: *mut hyperlinks_uri,
) {
    let mut parent: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut gparent: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut tmp: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    loop {
        parent = (*elm).by_inner_entry.rbe_parent;
        if parent.is_null() || (*parent).by_inner_entry.rbe_color != 1 as i32 {
            break;
        }
        gparent = (*parent).by_inner_entry.rbe_parent;
        if parent == (*gparent).by_inner_entry.rbe_left {
            tmp = (*gparent).by_inner_entry.rbe_right;
            if !tmp.is_null() && (*tmp).by_inner_entry.rbe_color == 1 as i32 {
                (*tmp).by_inner_entry.rbe_color = 0 as i32;
                (*parent).by_inner_entry.rbe_color = 0 as i32;
                (*gparent).by_inner_entry.rbe_color = 1 as i32;
                elm = gparent;
            } else {
                if (*parent).by_inner_entry.rbe_right == elm {
                    tmp = (*parent).by_inner_entry.rbe_right;
                    (*parent).by_inner_entry.rbe_right = (*tmp).by_inner_entry.rbe_left;
                    if !((*parent).by_inner_entry.rbe_right).is_null() {
                        (*(*tmp).by_inner_entry.rbe_left).by_inner_entry.rbe_parent = parent;
                    }
                    (*tmp).by_inner_entry.rbe_parent = (*parent).by_inner_entry.rbe_parent;
                    if !((*tmp).by_inner_entry.rbe_parent).is_null() {
                        if parent
                            == (*(*parent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_left
                        {
                            (*(*parent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_left = tmp;
                        } else {
                            (*(*parent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_right = tmp;
                        }
                    } else {
                        (*head).rbh_root = tmp;
                    }
                    (*tmp).by_inner_entry.rbe_left = parent;
                    (*parent).by_inner_entry.rbe_parent = tmp;
                    !((*tmp).by_inner_entry.rbe_parent).is_null();
                    tmp = parent;
                    parent = elm;
                    elm = tmp;
                }
                (*parent).by_inner_entry.rbe_color = 0 as i32;
                (*gparent).by_inner_entry.rbe_color = 1 as i32;
                tmp = (*gparent).by_inner_entry.rbe_left;
                (*gparent).by_inner_entry.rbe_left = (*tmp).by_inner_entry.rbe_right;
                if !((*gparent).by_inner_entry.rbe_left).is_null() {
                    (*(*tmp).by_inner_entry.rbe_right).by_inner_entry.rbe_parent = gparent;
                }
                (*tmp).by_inner_entry.rbe_parent = (*gparent).by_inner_entry.rbe_parent;
                if !((*tmp).by_inner_entry.rbe_parent).is_null() {
                    if gparent
                        == (*(*gparent).by_inner_entry.rbe_parent)
                            .by_inner_entry
                            .rbe_left
                    {
                        (*(*gparent).by_inner_entry.rbe_parent)
                            .by_inner_entry
                            .rbe_left = tmp;
                    } else {
                        (*(*gparent).by_inner_entry.rbe_parent)
                            .by_inner_entry
                            .rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).by_inner_entry.rbe_right = gparent;
                (*gparent).by_inner_entry.rbe_parent = tmp;
                !((*tmp).by_inner_entry.rbe_parent).is_null();
            }
        } else {
            tmp = (*gparent).by_inner_entry.rbe_left;
            if !tmp.is_null() && (*tmp).by_inner_entry.rbe_color == 1 as i32 {
                (*tmp).by_inner_entry.rbe_color = 0 as i32;
                (*parent).by_inner_entry.rbe_color = 0 as i32;
                (*gparent).by_inner_entry.rbe_color = 1 as i32;
                elm = gparent;
            } else {
                if (*parent).by_inner_entry.rbe_left == elm {
                    tmp = (*parent).by_inner_entry.rbe_left;
                    (*parent).by_inner_entry.rbe_left = (*tmp).by_inner_entry.rbe_right;
                    if !((*parent).by_inner_entry.rbe_left).is_null() {
                        (*(*tmp).by_inner_entry.rbe_right).by_inner_entry.rbe_parent = parent;
                    }
                    (*tmp).by_inner_entry.rbe_parent = (*parent).by_inner_entry.rbe_parent;
                    if !((*tmp).by_inner_entry.rbe_parent).is_null() {
                        if parent
                            == (*(*parent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_left
                        {
                            (*(*parent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_left = tmp;
                        } else {
                            (*(*parent).by_inner_entry.rbe_parent)
                                .by_inner_entry
                                .rbe_right = tmp;
                        }
                    } else {
                        (*head).rbh_root = tmp;
                    }
                    (*tmp).by_inner_entry.rbe_right = parent;
                    (*parent).by_inner_entry.rbe_parent = tmp;
                    !((*tmp).by_inner_entry.rbe_parent).is_null();
                    tmp = parent;
                    parent = elm;
                    elm = tmp;
                }
                (*parent).by_inner_entry.rbe_color = 0 as i32;
                (*gparent).by_inner_entry.rbe_color = 1 as i32;
                tmp = (*gparent).by_inner_entry.rbe_right;
                (*gparent).by_inner_entry.rbe_right = (*tmp).by_inner_entry.rbe_left;
                if !((*gparent).by_inner_entry.rbe_right).is_null() {
                    (*(*tmp).by_inner_entry.rbe_left).by_inner_entry.rbe_parent = gparent;
                }
                (*tmp).by_inner_entry.rbe_parent = (*gparent).by_inner_entry.rbe_parent;
                if !((*tmp).by_inner_entry.rbe_parent).is_null() {
                    if gparent
                        == (*(*gparent).by_inner_entry.rbe_parent)
                            .by_inner_entry
                            .rbe_left
                    {
                        (*(*gparent).by_inner_entry.rbe_parent)
                            .by_inner_entry
                            .rbe_left = tmp;
                    } else {
                        (*(*gparent).by_inner_entry.rbe_parent)
                            .by_inner_entry
                            .rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).by_inner_entry.rbe_left = gparent;
                (*gparent).by_inner_entry.rbe_parent = tmp;
                !((*tmp).by_inner_entry.rbe_parent).is_null();
            }
        }
    }
    (*(*head).rbh_root).by_inner_entry.rbe_color = 0 as i32;
}
unsafe extern "C" fn hyperlinks_by_inner_tree_RB_MINMAX(
    mut head: *mut hyperlinks_by_inner_tree,
    mut val: i32,
) -> *mut hyperlinks_uri {
    let mut tmp: *mut hyperlinks_uri = (*head).rbh_root;
    let mut parent: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    while !tmp.is_null() {
        parent = tmp;
        if val < 0 as i32 {
            tmp = (*tmp).by_inner_entry.rbe_left;
        } else {
            tmp = (*tmp).by_inner_entry.rbe_right;
        }
    }
    return parent;
}
unsafe extern "C" fn hyperlinks_by_inner_tree_RB_INSERT(
    mut head: *mut hyperlinks_by_inner_tree,
    mut elm: *mut hyperlinks_uri,
) -> *mut hyperlinks_uri {
    let mut tmp: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut parent: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut comp: i32 = 0 as i32;
    tmp = (*head).rbh_root;
    while !tmp.is_null() {
        parent = tmp;
        comp = hyperlinks_by_inner_cmp(elm, parent);
        if comp < 0 as i32 {
            tmp = (*tmp).by_inner_entry.rbe_left;
        } else if comp > 0 as i32 {
            tmp = (*tmp).by_inner_entry.rbe_right;
        } else {
            return tmp;
        }
    }
    (*elm).by_inner_entry.rbe_parent = parent;
    (*elm).by_inner_entry.rbe_right = std::ptr::null_mut::<hyperlinks_uri>();
    (*elm).by_inner_entry.rbe_left = (*elm).by_inner_entry.rbe_right;
    (*elm).by_inner_entry.rbe_color = 1 as i32;
    if !parent.is_null() {
        if comp < 0 as i32 {
            (*parent).by_inner_entry.rbe_left = elm;
        } else {
            (*parent).by_inner_entry.rbe_right = elm;
        }
    } else {
        (*head).rbh_root = elm;
    }
    hyperlinks_by_inner_tree_RB_INSERT_COLOR(head, elm);
    return std::ptr::null_mut::<hyperlinks_uri>();
}
unsafe extern "C" fn hyperlinks_by_inner_tree_RB_REMOVE_COLOR(
    mut head: *mut hyperlinks_by_inner_tree,
    mut parent: *mut hyperlinks_uri,
    mut elm: *mut hyperlinks_uri,
) {
    let mut tmp: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    while (elm.is_null() || (*elm).by_inner_entry.rbe_color == 0 as i32)
        && elm != (*head).rbh_root
    {
        if (*parent).by_inner_entry.rbe_left == elm {
            tmp = (*parent).by_inner_entry.rbe_right;
            if (*tmp).by_inner_entry.rbe_color == 1 as i32 {
                (*tmp).by_inner_entry.rbe_color = 0 as i32;
                (*parent).by_inner_entry.rbe_color = 1 as i32;
                tmp = (*parent).by_inner_entry.rbe_right;
                (*parent).by_inner_entry.rbe_right = (*tmp).by_inner_entry.rbe_left;
                if !((*parent).by_inner_entry.rbe_right).is_null() {
                    (*(*tmp).by_inner_entry.rbe_left).by_inner_entry.rbe_parent = parent;
                }
                (*tmp).by_inner_entry.rbe_parent = (*parent).by_inner_entry.rbe_parent;
                if !((*tmp).by_inner_entry.rbe_parent).is_null() {
                    if parent
                        == (*(*parent).by_inner_entry.rbe_parent)
                            .by_inner_entry
                            .rbe_left
                    {
                        (*(*parent).by_inner_entry.rbe_parent)
                            .by_inner_entry
                            .rbe_left = tmp;
                    } else {
                        (*(*parent).by_inner_entry.rbe_parent)
                            .by_inner_entry
                            .rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).by_inner_entry.rbe_left = parent;
                (*parent).by_inner_entry.rbe_parent = tmp;
                !((*tmp).by_inner_entry.rbe_parent).is_null();
                tmp = (*parent).by_inner_entry.rbe_right;
            }
            if (((*tmp).by_inner_entry.rbe_left).is_null()
                || (*(*tmp).by_inner_entry.rbe_left).by_inner_entry.rbe_color == 0 as i32)
                && (((*tmp).by_inner_entry.rbe_right).is_null()
                    || (*(*tmp).by_inner_entry.rbe_right).by_inner_entry.rbe_color
                        == 0 as i32)
            {
                (*tmp).by_inner_entry.rbe_color = 1 as i32;
                elm = parent;
                parent = (*elm).by_inner_entry.rbe_parent;
            } else {
                if ((*tmp).by_inner_entry.rbe_right).is_null()
                    || (*(*tmp).by_inner_entry.rbe_right).by_inner_entry.rbe_color
                        == 0 as i32
                {
                    let mut oleft: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
                    oleft = (*tmp).by_inner_entry.rbe_left;
                    if !oleft.is_null() {
                        (*oleft).by_inner_entry.rbe_color = 0 as i32;
                    }
                    (*tmp).by_inner_entry.rbe_color = 1 as i32;
                    oleft = (*tmp).by_inner_entry.rbe_left;
                    (*tmp).by_inner_entry.rbe_left = (*oleft).by_inner_entry.rbe_right;
                    if !((*tmp).by_inner_entry.rbe_left).is_null() {
                        (*(*oleft).by_inner_entry.rbe_right)
                            .by_inner_entry
                            .rbe_parent = tmp;
                    }
                    (*oleft).by_inner_entry.rbe_parent = (*tmp).by_inner_entry.rbe_parent;
                    if !((*oleft).by_inner_entry.rbe_parent).is_null() {
                        if tmp == (*(*tmp).by_inner_entry.rbe_parent).by_inner_entry.rbe_left {
                            (*(*tmp).by_inner_entry.rbe_parent).by_inner_entry.rbe_left = oleft;
                        } else {
                            (*(*tmp).by_inner_entry.rbe_parent).by_inner_entry.rbe_right = oleft;
                        }
                    } else {
                        (*head).rbh_root = oleft;
                    }
                    (*oleft).by_inner_entry.rbe_right = tmp;
                    (*tmp).by_inner_entry.rbe_parent = oleft;
                    !((*oleft).by_inner_entry.rbe_parent).is_null();
                    tmp = (*parent).by_inner_entry.rbe_right;
                }
                (*tmp).by_inner_entry.rbe_color = (*parent).by_inner_entry.rbe_color;
                (*parent).by_inner_entry.rbe_color = 0 as i32;
                if !((*tmp).by_inner_entry.rbe_right).is_null() {
                    (*(*tmp).by_inner_entry.rbe_right).by_inner_entry.rbe_color = 0 as i32;
                }
                tmp = (*parent).by_inner_entry.rbe_right;
                (*parent).by_inner_entry.rbe_right = (*tmp).by_inner_entry.rbe_left;
                if !((*parent).by_inner_entry.rbe_right).is_null() {
                    (*(*tmp).by_inner_entry.rbe_left).by_inner_entry.rbe_parent = parent;
                }
                (*tmp).by_inner_entry.rbe_parent = (*parent).by_inner_entry.rbe_parent;
                if !((*tmp).by_inner_entry.rbe_parent).is_null() {
                    if parent
                        == (*(*parent).by_inner_entry.rbe_parent)
                            .by_inner_entry
                            .rbe_left
                    {
                        (*(*parent).by_inner_entry.rbe_parent)
                            .by_inner_entry
                            .rbe_left = tmp;
                    } else {
                        (*(*parent).by_inner_entry.rbe_parent)
                            .by_inner_entry
                            .rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).by_inner_entry.rbe_left = parent;
                (*parent).by_inner_entry.rbe_parent = tmp;
                !((*tmp).by_inner_entry.rbe_parent).is_null();
                elm = (*head).rbh_root;
                break;
            }
        } else {
            tmp = (*parent).by_inner_entry.rbe_left;
            if (*tmp).by_inner_entry.rbe_color == 1 as i32 {
                (*tmp).by_inner_entry.rbe_color = 0 as i32;
                (*parent).by_inner_entry.rbe_color = 1 as i32;
                tmp = (*parent).by_inner_entry.rbe_left;
                (*parent).by_inner_entry.rbe_left = (*tmp).by_inner_entry.rbe_right;
                if !((*parent).by_inner_entry.rbe_left).is_null() {
                    (*(*tmp).by_inner_entry.rbe_right).by_inner_entry.rbe_parent = parent;
                }
                (*tmp).by_inner_entry.rbe_parent = (*parent).by_inner_entry.rbe_parent;
                if !((*tmp).by_inner_entry.rbe_parent).is_null() {
                    if parent
                        == (*(*parent).by_inner_entry.rbe_parent)
                            .by_inner_entry
                            .rbe_left
                    {
                        (*(*parent).by_inner_entry.rbe_parent)
                            .by_inner_entry
                            .rbe_left = tmp;
                    } else {
                        (*(*parent).by_inner_entry.rbe_parent)
                            .by_inner_entry
                            .rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).by_inner_entry.rbe_right = parent;
                (*parent).by_inner_entry.rbe_parent = tmp;
                !((*tmp).by_inner_entry.rbe_parent).is_null();
                tmp = (*parent).by_inner_entry.rbe_left;
            }
            if (((*tmp).by_inner_entry.rbe_left).is_null()
                || (*(*tmp).by_inner_entry.rbe_left).by_inner_entry.rbe_color == 0 as i32)
                && (((*tmp).by_inner_entry.rbe_right).is_null()
                    || (*(*tmp).by_inner_entry.rbe_right).by_inner_entry.rbe_color
                        == 0 as i32)
            {
                (*tmp).by_inner_entry.rbe_color = 1 as i32;
                elm = parent;
                parent = (*elm).by_inner_entry.rbe_parent;
            } else {
                if ((*tmp).by_inner_entry.rbe_left).is_null()
                    || (*(*tmp).by_inner_entry.rbe_left).by_inner_entry.rbe_color
                        == 0 as i32
                {
                    let mut oright: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
                    oright = (*tmp).by_inner_entry.rbe_right;
                    if !oright.is_null() {
                        (*oright).by_inner_entry.rbe_color = 0 as i32;
                    }
                    (*tmp).by_inner_entry.rbe_color = 1 as i32;
                    oright = (*tmp).by_inner_entry.rbe_right;
                    (*tmp).by_inner_entry.rbe_right = (*oright).by_inner_entry.rbe_left;
                    if !((*tmp).by_inner_entry.rbe_right).is_null() {
                        (*(*oright).by_inner_entry.rbe_left)
                            .by_inner_entry
                            .rbe_parent = tmp;
                    }
                    (*oright).by_inner_entry.rbe_parent = (*tmp).by_inner_entry.rbe_parent;
                    if !((*oright).by_inner_entry.rbe_parent).is_null() {
                        if tmp == (*(*tmp).by_inner_entry.rbe_parent).by_inner_entry.rbe_left {
                            (*(*tmp).by_inner_entry.rbe_parent).by_inner_entry.rbe_left = oright;
                        } else {
                            (*(*tmp).by_inner_entry.rbe_parent).by_inner_entry.rbe_right = oright;
                        }
                    } else {
                        (*head).rbh_root = oright;
                    }
                    (*oright).by_inner_entry.rbe_left = tmp;
                    (*tmp).by_inner_entry.rbe_parent = oright;
                    !((*oright).by_inner_entry.rbe_parent).is_null();
                    tmp = (*parent).by_inner_entry.rbe_left;
                }
                (*tmp).by_inner_entry.rbe_color = (*parent).by_inner_entry.rbe_color;
                (*parent).by_inner_entry.rbe_color = 0 as i32;
                if !((*tmp).by_inner_entry.rbe_left).is_null() {
                    (*(*tmp).by_inner_entry.rbe_left).by_inner_entry.rbe_color = 0 as i32;
                }
                tmp = (*parent).by_inner_entry.rbe_left;
                (*parent).by_inner_entry.rbe_left = (*tmp).by_inner_entry.rbe_right;
                if !((*parent).by_inner_entry.rbe_left).is_null() {
                    (*(*tmp).by_inner_entry.rbe_right).by_inner_entry.rbe_parent = parent;
                }
                (*tmp).by_inner_entry.rbe_parent = (*parent).by_inner_entry.rbe_parent;
                if !((*tmp).by_inner_entry.rbe_parent).is_null() {
                    if parent
                        == (*(*parent).by_inner_entry.rbe_parent)
                            .by_inner_entry
                            .rbe_left
                    {
                        (*(*parent).by_inner_entry.rbe_parent)
                            .by_inner_entry
                            .rbe_left = tmp;
                    } else {
                        (*(*parent).by_inner_entry.rbe_parent)
                            .by_inner_entry
                            .rbe_right = tmp;
                    }
                } else {
                    (*head).rbh_root = tmp;
                }
                (*tmp).by_inner_entry.rbe_right = parent;
                (*parent).by_inner_entry.rbe_parent = tmp;
                !((*tmp).by_inner_entry.rbe_parent).is_null();
                elm = (*head).rbh_root;
                break;
            }
        }
    }
    if !elm.is_null() {
        (*elm).by_inner_entry.rbe_color = 0 as i32;
    }
}
unsafe extern "C" fn hyperlinks_by_inner_tree_RB_REMOVE(
    mut head: *mut hyperlinks_by_inner_tree,
    mut elm: *mut hyperlinks_uri,
) -> *mut hyperlinks_uri {
    let mut current_block: u64;
    let mut child: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut parent: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut old: *mut hyperlinks_uri = elm;
    let mut color: i32 = 0;
    if ((*elm).by_inner_entry.rbe_left).is_null() {
        child = (*elm).by_inner_entry.rbe_right;
        current_block = 7245201122033322888;
    } else if ((*elm).by_inner_entry.rbe_right).is_null() {
        child = (*elm).by_inner_entry.rbe_left;
        current_block = 7245201122033322888;
    } else {
        let mut left: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
        elm = (*elm).by_inner_entry.rbe_right;
        loop {
            left = (*elm).by_inner_entry.rbe_left;
            if left.is_null() {
                break;
            }
            elm = left;
        }
        child = (*elm).by_inner_entry.rbe_right;
        parent = (*elm).by_inner_entry.rbe_parent;
        color = (*elm).by_inner_entry.rbe_color;
        if !child.is_null() {
            (*child).by_inner_entry.rbe_parent = parent;
        }
        if !parent.is_null() {
            if (*parent).by_inner_entry.rbe_left == elm {
                (*parent).by_inner_entry.rbe_left = child;
            } else {
                (*parent).by_inner_entry.rbe_right = child;
            }
        } else {
            (*head).rbh_root = child;
        }
        if (*elm).by_inner_entry.rbe_parent == old {
            parent = elm;
        }
        (*elm).by_inner_entry = (*old).by_inner_entry;
        if !((*old).by_inner_entry.rbe_parent).is_null() {
            if (*(*old).by_inner_entry.rbe_parent).by_inner_entry.rbe_left == old {
                (*(*old).by_inner_entry.rbe_parent).by_inner_entry.rbe_left = elm;
            } else {
                (*(*old).by_inner_entry.rbe_parent).by_inner_entry.rbe_right = elm;
            }
        } else {
            (*head).rbh_root = elm;
        }
        (*(*old).by_inner_entry.rbe_left).by_inner_entry.rbe_parent = elm;
        if !((*old).by_inner_entry.rbe_right).is_null() {
            (*(*old).by_inner_entry.rbe_right).by_inner_entry.rbe_parent = elm;
        }
        if !parent.is_null() {
            left = parent;
            loop {
                left = (*left).by_inner_entry.rbe_parent;
                if left.is_null() {
                    break;
                }
            }
        }
        current_block = 11121321688420496970;
    }
    match current_block {
        7245201122033322888 => {
            parent = (*elm).by_inner_entry.rbe_parent;
            color = (*elm).by_inner_entry.rbe_color;
            if !child.is_null() {
                (*child).by_inner_entry.rbe_parent = parent;
            }
            if !parent.is_null() {
                if (*parent).by_inner_entry.rbe_left == elm {
                    (*parent).by_inner_entry.rbe_left = child;
                } else {
                    (*parent).by_inner_entry.rbe_right = child;
                }
            } else {
                (*head).rbh_root = child;
            }
        }
        _ => {}
    }
    if color == 0 as i32 {
        hyperlinks_by_inner_tree_RB_REMOVE_COLOR(head, parent, child);
    }
    return old;
}
unsafe extern "C" fn hyperlinks_by_inner_tree_RB_FIND(
    mut head: *mut hyperlinks_by_inner_tree,
    mut elm: *mut hyperlinks_uri,
) -> *mut hyperlinks_uri {
    let mut tmp: *mut hyperlinks_uri = (*head).rbh_root;
    let mut comp: i32 = 0;
    while !tmp.is_null() {
        comp = hyperlinks_by_inner_cmp(elm, tmp);
        if comp < 0 as i32 {
            tmp = (*tmp).by_inner_entry.rbe_left;
        } else if comp > 0 as i32 {
            tmp = (*tmp).by_inner_entry.rbe_right;
        } else {
            return tmp;
        }
    }
    return std::ptr::null_mut::<hyperlinks_uri>();
}
unsafe extern "C" fn hyperlinks_remove(mut hlu: *mut hyperlinks_uri) {
    let mut hl: *mut hyperlinks = (*hlu).tree;
    if !((*hlu).list_entry.tqe_next).is_null() {
        (*(*hlu).list_entry.tqe_next).list_entry.tqe_prev = (*hlu).list_entry.tqe_prev;
    } else {
        global_hyperlinks.tqh_last = (*hlu).list_entry.tqe_prev;
    }
    *(*hlu).list_entry.tqe_prev = (*hlu).list_entry.tqe_next;
    global_hyperlinks_count = global_hyperlinks_count.wrapping_sub(1);
    hyperlinks_by_inner_tree_RB_REMOVE(&mut (*hl).by_inner, hlu);
    hyperlinks_by_uri_tree_RB_REMOVE(&mut (*hl).by_uri, hlu);
    free((*hlu).internal_id as *mut libc::c_void);
    free((*hlu).external_id as *mut libc::c_void);
    free((*hlu).uri as *mut libc::c_void);
    free(hlu as *mut libc::c_void);
}
#[no_mangle]
pub unsafe extern "C" fn hyperlinks_put(
    mut hl: *mut hyperlinks,
    mut uri_in: *const i8,
    mut internal_id_in: *const i8,
) -> u_int {
    let mut find: hyperlinks_uri = hyperlinks_uri {
        tree: std::ptr::null_mut::<hyperlinks>(),
        inner: 0,
        internal_id: std::ptr::null::<i8>(),
        external_id: std::ptr::null::<i8>(),
        uri: std::ptr::null::<i8>(),
        list_entry: C2RustUnnamed_1 {
            tqe_next: std::ptr::null_mut::<hyperlinks_uri>(),
            tqe_prev: std::ptr::null_mut::<*mut hyperlinks_uri>(),
        },
        by_inner_entry: C2RustUnnamed_0 {
            rbe_left: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_right: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_parent: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_color: 0,
        },
        by_uri_entry: C2RustUnnamed {
            rbe_left: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_right: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_parent: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_color: 0,
        },
    };
    let mut hlu: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut uri: *mut i8 = std::ptr::null_mut::<i8>();
    let mut internal_id: *mut i8 = std::ptr::null_mut::<i8>();
    let mut external_id: *mut i8 = std::ptr::null_mut::<i8>();
    if internal_id_in.is_null() {
        internal_id_in = b"\0" as *const u8 as *const i8;
    }
    utf8_stravis(&mut uri, uri_in, 0x1 as i32 | 0x2 as i32);
    utf8_stravis(
        &mut internal_id,
        internal_id_in,
        0x1 as i32 | 0x2 as i32,
    );
    if *internal_id_in as i32 != '\0' as i32 {
        find.uri = uri;
        find.internal_id = internal_id;
        hlu = hyperlinks_by_uri_tree_RB_FIND(&mut (*hl).by_uri, &mut find);
        if !hlu.is_null() {
            free(uri as *mut libc::c_void);
            free(internal_id as *mut libc::c_void);
            return (*hlu).inner;
        }
    }
    let fresh0 = hyperlinks_next_external_id;
    hyperlinks_next_external_id = hyperlinks_next_external_id + 1;
    xasprintf(
        &mut external_id as *mut *mut i8,
        b"tmux%llX\0" as *const u8 as *const i8,
        fresh0,
    );
    hlu = xcalloc(
        1 as i32 as size_t,
        ::core::mem::size_of::<hyperlinks_uri>() as u64,
    ) as *mut hyperlinks_uri;
    let fresh1 = (*hl).next_inner;
    (*hl).next_inner = ((*hl).next_inner).wrapping_add(1);
    (*hlu).inner = fresh1;
    (*hlu).internal_id = internal_id;
    (*hlu).external_id = external_id;
    (*hlu).uri = uri;
    (*hlu).tree = hl;
    hyperlinks_by_uri_tree_RB_INSERT(&mut (*hl).by_uri, hlu);
    hyperlinks_by_inner_tree_RB_INSERT(&mut (*hl).by_inner, hlu);
    (*hlu).list_entry.tqe_next = std::ptr::null_mut::<hyperlinks_uri>();
    (*hlu).list_entry.tqe_prev = global_hyperlinks.tqh_last;
    *global_hyperlinks.tqh_last = hlu;
    global_hyperlinks.tqh_last = &mut (*hlu).list_entry.tqe_next;
    global_hyperlinks_count = global_hyperlinks_count.wrapping_add(1);
    if global_hyperlinks_count == 5000 as i32 as u32 {
        hyperlinks_remove(global_hyperlinks.tqh_first);
    }
    return (*hlu).inner;
}
#[no_mangle]
pub unsafe extern "C" fn hyperlinks_get(
    mut hl: *mut hyperlinks,
    mut inner: u_int,
    mut uri_out: *mut *const i8,
    mut internal_id_out: *mut *const i8,
    mut external_id_out: *mut *const i8,
) -> i32 {
    let mut find: hyperlinks_uri = hyperlinks_uri {
        tree: std::ptr::null_mut::<hyperlinks>(),
        inner: 0,
        internal_id: std::ptr::null::<i8>(),
        external_id: std::ptr::null::<i8>(),
        uri: std::ptr::null::<i8>(),
        list_entry: C2RustUnnamed_1 {
            tqe_next: std::ptr::null_mut::<hyperlinks_uri>(),
            tqe_prev: std::ptr::null_mut::<*mut hyperlinks_uri>(),
        },
        by_inner_entry: C2RustUnnamed_0 {
            rbe_left: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_right: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_parent: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_color: 0,
        },
        by_uri_entry: C2RustUnnamed {
            rbe_left: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_right: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_parent: std::ptr::null_mut::<hyperlinks_uri>(),
            rbe_color: 0,
        },
    };
    let mut hlu: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    find.inner = inner;
    hlu = hyperlinks_by_inner_tree_RB_FIND(&mut (*hl).by_inner, &mut find);
    if hlu.is_null() {
        return 0 as i32;
    }
    if !internal_id_out.is_null() {
        *internal_id_out = (*hlu).internal_id;
    }
    if !external_id_out.is_null() {
        *external_id_out = (*hlu).external_id;
    }
    *uri_out = (*hlu).uri;
    return 1 as i32;
}
#[no_mangle]
pub unsafe extern "C" fn hyperlinks_init() -> *mut hyperlinks {
    let mut hl: *mut hyperlinks = std::ptr::null_mut::<hyperlinks>();
    hl = xcalloc(
        1 as i32 as size_t,
        ::core::mem::size_of::<hyperlinks>() as u64,
    ) as *mut hyperlinks;
    (*hl).next_inner = 1 as i32 as u_int;
    (*hl).by_uri.rbh_root = std::ptr::null_mut::<hyperlinks_uri>();
    (*hl).by_inner.rbh_root = std::ptr::null_mut::<hyperlinks_uri>();
    (*hl).references = 1 as i32 as u_int;
    return hl;
}
#[no_mangle]
pub unsafe extern "C" fn hyperlinks_copy(mut hl: *mut hyperlinks) -> *mut hyperlinks {
    (*hl).references = ((*hl).references).wrapping_add(1);
    return hl;
}
#[no_mangle]
pub unsafe extern "C" fn hyperlinks_reset(mut hl: *mut hyperlinks) {
    let mut hlu: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    let mut hlu1: *mut hyperlinks_uri = std::ptr::null_mut::<hyperlinks_uri>();
    hlu = hyperlinks_by_inner_tree_RB_MINMAX(&mut (*hl).by_inner, -(1 as i32));
    while !hlu.is_null() && {
        hlu1 = hyperlinks_by_inner_tree_RB_NEXT(hlu);
        1 as i32 != 0
    } {
        hyperlinks_remove(hlu);
        hlu = hlu1;
    }
}
#[no_mangle]
pub unsafe extern "C" fn hyperlinks_free(mut hl: *mut hyperlinks) {
    (*hl).references = ((*hl).references).wrapping_sub(1);
    if (*hl).references == 0 as i32 as u32 {
        hyperlinks_reset(hl);
        free(hl as *mut libc::c_void);
    }
}
unsafe extern "C" fn run_static_initializers() {
    global_hyperlinks = {
        let mut init = hyperlinks_list {
            tqh_first: std::ptr::null_mut::<hyperlinks_uri>(),
            tqh_last: &mut global_hyperlinks.tqh_first,
        };
        init
    };
}
#[used]
#[cfg_attr(target_os = "linux", link_section = ".init_array")]
#[cfg_attr(target_os = "windows", link_section = ".CRT$XIB")]
#[cfg_attr(target_os = "macos", link_section = "__DATA,__mod_init_func")]
static INIT_ARRAY: [unsafe extern "C" fn(); 1] = [run_static_initializers];
